<template>
	<view :style="viewColor"  class='productSort'>
			<!-- <view class='search acea-row row-between-wrapper'>
				<view class='input acea-row row-between-wrapper'>
					<text class='iconfont icon-sousuo2'></text>
					<input type='text' v-model="tabForm.title" placeholder='请输入关键字' placeholder-class='placeholder'></input>
				</view>
				<view class='bnt' @tap='searchCircle'>搜索</view>
			</view> -->
			<view v-if="list_circle.length" class="circle-list">
				<view v-for="(item, index) in list_circle" :key="index" class="circle-item">
					<view class='circle-item-avatar'>
						<image :src="item.avatar" />
					</view>
					<view class='circle-item-info'>
						<view class='circle-item-title'>{{item.title}}</view>
						<!-- <view class='circle-item-label_name'>{{item.label.list[0].label_name}}{{item.label.list[1] ? '-' + item.label.list[1].label_name : ''}}</view> -->
						<view class="circle-item-gz">
							<image class="circle-item-gz-icon" :src="domain + '/uploads/default/20230628/2c7d68b982302e32ccfa8c0a3d922319.png'" />
							<view  class="circle-item-gz-num">{{item.user_circle_count}}粉丝</view>
						</view>
						<view class="circle-item-gz-user">
							<view class="circle-item-gz-tl">{{item.circle_community_count}} 人在讨论</view>
						</view>
						
						<view class="circle-item-gz-user">
							<image class="circle-item-gz-avatar" v-for="(v,i) in item.user_circle" :key="i" :src="v.user.avatar || '/static/images/f.png'" />
							<image class="circle-item-gz-avatar" :src="domain + '/uploads/default/20230629/436303b1fccbd3e1714b11990d5b7e28.png'" />
						</view>
						
					</view>
					<view class='circle-item-button'>
						<view class="circle-item-button_btn" @click="getCircleInfo(item.id)">{{item.is_user_circle ? '进入' : '加入'}}</view>
					</view>
				</view>
			</view>
	</view>
</template>
<script>
	 
	let app = getApp(); 
	import { getListCircle, getAttentionCircle } from '@/api/circle.js';
	import { configMap } from '@/utils/index';
	// #ifndef H5
	import passwordPopup from '@/components/passwordPopup';
	// #endif
	import { mapGetters } from "vuex";
	import { HTTP_REQUEST_URL } from '@/config/app';
	export default {
		components: {
			// #ifndef H5
			passwordPopup,
			// #endif
		},
		computed: configMap({navigation: {}, is_community_video_start: 0},mapGetters(['isLogin','viewColor','keyColor'])),
		data() {
			let active = 0;
			return {
				domain: HTTP_REQUEST_URL,
				list_circle: [],
				is_next_page_true: true,
				tabForm: {
					page: 1,
					limit: 10,
					label_id: '',
					label_id2: '',
					title: '',
					tabIndex: 1,
				}
			}
		},
		onLoad(options) {
			let that = this;
			that.tabForm.label_id = options.label_id || '';
			that.tabForm.label_id2 = options.label_id2 || '';
			if (options.is_hot && options.is_hot == 1) {
				uni.setNavigationBarTitle({
					title: '热门人脉圈'
				})
			}
			that.getListCircles()
		},
		methods: {
			getListCircles()
			{
				let that = this;
				if(!that.is_next_page_true) return false;
				getListCircle(that.tabForm).then(res => {
					if(res.status == 200)
					{
						that.list_circle = that.list_circle.concat(res.data.list)
						that.is_next_page_true = res.data.list.length >= that.tabForm.limit;
						that.tabForm.page++
					}
				}).catch(err=>{
				})
			},
			getCircleInfo(circle_id) {
				let that = this;
				if(!that.isLogin) return that.$util.Tips({title:'请先登录'}, {tab: 1, url: '/pages/user/index'})
				getAttentionCircle(circle_id).then(res=>{
					if(res.status == 200 && res.data.pay_type){
						return that.$util.Tips('/pages/extends/circle_create/circle_info?id='+circle_id)
					}
					return that.$util.Tips('/pages/extends/circle_create/circle_pay?id='+circle_id);
				}).catch(err=>{
					that.$util.Tips({title: err})
				})
			},
		},
		onReachBottom() {
			this.getListCircles();
		}
	}
</script>
<style scoped lang="scss">
	.productSort {
		display: flex;
		flex-direction: column;
		width: 100%;
		.con-box {
			flex: 1;
			display: flex;
			overflow: hidden;
		}
		.search {
			padding: 20rpx 0 20rpx 30rpx;
			background-color: #fff;
		}
		.search .input {
			width: 598rpx;
			background-color: #f7f7f7;
			border-radius: 33rpx;
			padding: 0 35rpx;
			box-sizing: border-box;
			height: 66rpx;
		}
		.search .input input {
			width: 472rpx;
			font-size: 28rpx;
		}
		.search .input .placeholder {
			color: #bbb;
		}
		.search .input .iconfont {
			color: #000;
			font-size: 35rpx;
		}
		.search .bnt {
			width: 120rpx;
			text-align: center;
			height: 66rpx;
			line-height: 66rpx;
			font-size: 30rpx;
			color: #282828;
		}
	}
	.list {
		flex-wrap: wrap;
		background: #fff;
		border-radius: 16rpx;
		padding-bottom: 26rpx;
		.item {
			width: 174rpx;
			margin-top: 26rpx;
		}
	}
	.list .item .picture,uni-image,.list .item image,::v-deep.easy-loadimage{
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
	}
	.list .item .name {
		font-size: 24rpx;
		color: #333;
		height: 56rpx;
		line-height: 56rpx;
		width: 120rpx;
		text-align: center;
	}
	// 人脉圈列表2
	.circle-item {
		display: flex;
		// margin: 10rpx 10rpx 0;
		padding: 30rpx;
		background-color: #fff;
		margin-top: 20rpx;
		.circle-item-avatar image{
			width: 160rpx;
			height: 160rpx;
			border-radius: 20rpx;
		}
		.circle-item-info {
			flex: 1;
			margin-left: 20rpx;
			padding-top: 10rpx;
			overflow: hidden;
			.circle-item-title {
				font-size: 36rpx;
				font-weight: bold;
				color: #323232;
				line-height: 44rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
			.circle-item-label_name {
				margin-top: 10rpx;
				    font-size: 24rpx;
			}
			.circle-item-gz {
				display: flex;
				align-items: center;
				margin-top: 12rpx;
				.circle-item-gz-icon {
					width: 28rpx;
					height: 28rpx;
				}
				.circle-item-gz-num {
					font-size: 24rpx;
					font-weight: 400;
					color: #323232;
					line-height: 34rpx;
					margin-left: 4rpx;
				}
			}
			.circle-item-gz-user {
				display: flex;
				align-items: center;
				margin-top: 20rpx;
				image {
					width: 44rpx;
					height: 44rpx;
					border-radius: 100%;
					margin-left: -10rpx;
				}
				image:first-child {
					margin-left: 0rpx;
				}
			}
			.circle-item-gz-tl {
				font-size: 20rpx;
				font-weight: 400;
				color: #323232;
				line-height: 28rpx;
				margin-left: 10rpx;
			}
		}
		.circle-item-button {
			margin-left: auto;
			display: flex;
			align-items: center;
			.circle-item-button_btn {
				font-size: 30rpx;
				font-weight: 500;
				color: #1C211D;
				line-height: 42rpx;
				background: #FFE103;
				border-radius: 37rpx;
				padding: 16rpx 42rpx;
			}
		}
	}
	
</style>